home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 35.1 KB | 1,043 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEvent.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWMAPING_H
- #include "FWMaping.h"
- #endif
-
- #ifndef FWFCTINF_H
- #include "FWFctInf.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- // ----- OpenDoc Includes -----
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
- #include <Drag.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #pragma segment fwevents
-
- FW_DEFINE_CLASS_M0(FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CNullEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CMouseEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CEmbeddedMouseEvent, FW_CMouseEvent)
- FW_DEFINE_CLASS_M1(FW_CBorderMouseEvent, FW_CMouseEvent)
- FW_DEFINE_CLASS_M1(FW_CVirtualKeyEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CCharKeyEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CActivateEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CSuspendResumeEvent, FW_CSystemEvent)
- FW_DEFINE_CLASS_M1(FW_CMenuEvent, FW_CSystemEvent)
- #ifdef FW_BUILD_MAC
- FW_DEFINE_CLASS_M1(FW_CMacWindowEvent, FW_CSystemEvent)
- #endif
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- const short FW_CMouseEvent::kEmpty = 0;
- const short FW_CMouseEvent::kExtend = 1;
- const short FW_CMouseEvent::kItem = 2;
- const short FW_CMouseEvent::kCopy = 4;
- const short FW_CMouseEvent::kControl = 8;
-
- //========================================================================================
- // CLASS FW_CSystemEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time)
- {
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::SetMemory(&fEvent, sizeof(ODEventData), 0);
- fEvent.when = time;
- fPlatformWindow = theWindow;
- #endif
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::SetMemory(&fEvent, sizeof(MSG), 0);
- FW_ASSERT(theWindow != NULL);
- fEvent.hwnd = theWindow;
- fEvent.time = time;
- fPlatformWindow = theWindow;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, ODEventData* theEvent)
- {
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::CopyMemory(theEvent, &fEvent, sizeof(ODEventData));
- fPlatformWindow = NULL;
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::CopyMemory(theEvent, &fEvent, sizeof(MSG));
- fPlatformWindow = (HWND)fEvent.hwnd;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::FW_CSystemEvent(Environment* ev, const FW_CSystemEvent& other)
- {
- #ifdef FW_BUILD_MAC
- FW_CMemoryManager::CopyMemory(((FW_CSystemEvent&)other).GetPlatformEvent(), &fEvent, sizeof(ODEventData));
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CMemoryManager::CopyMemory(((FW_CSystemEvent&)other).GetPlatformEvent(), &fEvent, sizeof(MSG));
- #endif
-
- fPlatformWindow = other.GetPlatformWindow();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::~FW_CSystemEvent
- //----------------------------------------------------------------------------------------
- FW_CSystemEvent::~FW_CSystemEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CNullEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, ODEventData* theEvent) :
- FW_CSystemEvent(ev, theEvent)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time) :
- FW_CSystemEvent(ev, theWindow, time)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::FW_CNullEvent(Environment* ev, const FW_CNullEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = nullEvent;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_NULL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CNullEvent::~FW_CNullEvent
- //----------------------------------------------------------------------------------------
- FW_CNullEvent::~FW_CNullEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CMacWindowEvent
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMacWindowEvent::FW_CMacWindowEvent
- //----------------------------------------------------------------------------------------
- FW_CMacWindowEvent::FW_CMacWindowEvent(Environment* ev, ODEventData* theEvent) :
- FW_CSystemEvent(ev, theEvent)
- {
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CMacWindowEvent::~FW_CMacWindowEvent
- //----------------------------------------------------------------------------------------
- FW_CMacWindowEvent::~FW_CMacWindowEvent()
- {
- }
- #endif
-
- //========================================================================================
- // CLASS FW_CMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev, ODEventData* theEvent, ODFacet* theFacet, ButtonState theState, short numOfClicks) :
- FW_CSystemEvent(ev, theEvent),
- fFacet(theFacet),
- fButtonState(theState),
- fNumberOfClicks(numOfClicks)
- {
- #ifdef FW_BUILD_MAC
- fWhichButton = kLeftMouseButton;
- #endif
- #ifdef FW_BUILD_WIN
- if (theEvent->message == WM_LBUTTONDOWN || theEvent->message == WM_LBUTTONUP)
- fWhichButton = kLeftMouseButton;
- else if (theEvent->message == WM_MBUTTONDOWN || theEvent->message == WM_RBUTTONUP)
- fWhichButton = kMiddleMouseButton;
- else
- fWhichButton = kRightMouseButton;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev,
- ODFacet* theFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CSystemEvent(ev, theWindow, when),
- fFacet(theFacet),
- fButtonState(theState),
- fWhichButton(initialButton),
- fNumberOfClicks(numOfClicks)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = mouseDown;
- else
- fEvent.what = mouseUp;
-
- where.AsPlatformPoint(fEvent.where);
- if (modifiers & kExtend)
- fEvent.modifiers += shiftKey;
- if (modifiers & kItem)
- fEvent.modifiers += cmdKey;
- if (modifiers & kCopy)
- fEvent.modifiers += optionKey;
- if (modifiers & kControl)
- fEvent.modifiers += controlKey;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- {
- if (initialButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONDOWN;
- else if (initialButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONDOWN;
- else
- fEvent.message = WM_RBUTTONDOWN;
- }
- else
- {
- if (initialButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONUP;
- else if (initialButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONUP;
- else
- fEvent.message = WM_RBUTTONUP;
- }
-
- where.AsPlatformPoint(fEvent.pt);
- fEvent.lParam = fEvent.pt.y;
- fEvent.lParam = fEvent.lParam << 16;
- fEvent.lParam = fEvent.pt.x;
-
- if (modifiers & kExtend)
- fEvent.wParam += MK_SHIFT;
- if ((modifiers & kItem) || (modifiers & kCopy) || (modifiers & kControl))
- fEvent.wParam += MK_CONTROL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& embeddedEvent) :
- FW_CSystemEvent(ev, embeddedEvent)
- {
- fFacet = embeddedEvent.GetFacet(ev);
- fButtonState = embeddedEvent.GetButtonState(ev);
- fWhichButton = embeddedEvent.GetInitialButtonPressed(ev);
- fNumberOfClicks = embeddedEvent.GetNumberOfClicks(ev);
-
- #ifdef FW_BUILD_MAC
- if (fButtonState == kMouseButtonDown)
- fEvent.what = mouseDown;
- else
- fEvent.what = mouseUp;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (fButtonState == kMouseButtonDown)
- {
- if (fWhichButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONDOWN;
- else if (fWhichButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONDOWN;
- else
- fEvent.message = WM_RBUTTONDOWN;
- }
- else
- {
- if (fWhichButton == kLeftMouseButton)
- fEvent.message = WM_LBUTTONUP;
- else if (fWhichButton == kMiddleMouseButton)
- fEvent.message = WM_MBUTTONUP;
- else
- fEvent.message = WM_RBUTTONUP;
- }
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::FW_CMouseEvent(Environment* ev, const FW_CMouseEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fFacet = other.GetFacet(ev);
- fButtonState = other.GetButtonState(ev);
- fWhichButton = other.GetInitialButtonPressed(ev);
- fNumberOfClicks = other.GetNumberOfClicks(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::~FW_CMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CMouseEvent::~FW_CMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetButtonModifiers
- //----------------------------------------------------------------------------------------
- unsigned short FW_CMouseEvent::GetButtonModifiers(Environment* ev) const
- {
- unsigned short modifiers = kEmpty;
-
- if (this->IsExtendModifier(ev))
- modifiers |= kExtend;
- if (this->IsItemModifier(ev))
- modifiers |= kItem;
- if (this->IsCopyModifier(ev))
- modifiers |= kCopy;
- if (this->IsControlKeyModifier(ev))
- modifiers |= kControl;
-
- return modifiers;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetLogicalMousePosition
- //----------------------------------------------------------------------------------------
-
- FW_CPoint FW_CMouseEvent::GetLogicalMousePosition(Environment* ev,
- const FW_CMapping& mapping) const
- {
- // [LSD] use kFrame for now: to fix later
- FW_CPoint position = FW_CMouseEvent::GetMousePosition(ev, kFrame);
-
- // Note: I am calling DeviceToLogical and not LogicalToDevice because at this point position
- // is in "OpenDoc" coordinate (72 dpi on both platform) and I want it in logical coordinate
- FW_SPlatformPoint plfmPoint = position;
- mapping.DeviceToLogical(ev, plfmPoint, position, FW_CFacetPartInfo::GetFacetGraphicDevice(ev, fFacet), NULL);
-
- return position;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetMousePosition
- //----------------------------------------------------------------------------------------
- // [LSD] This cannot return a position in Content coordinates because the ContentView may
- // not be at the frame's origin. Get Frame coordinates and convert to Content afterward.
-
- FW_CPoint FW_CMouseEvent::GetMousePosition(Environment* ev,
- ECoordinates coordinate) const
- {
- #ifdef FW_BUILD_MAC
- FW_SPlatformPoint mousePos(fEvent.where);
- #endif
- #ifdef FW_BUILD_WIN
- FW_SPlatformPoint mousePos(fEvent.pt);
- #endif
-
- // ----- Convert into window coordinates -----
- if (coordinate != kScreen)
- {
- #ifdef FW_BUILD_MAC
- ODWindow* aqWindow = fFacet->GetWindow(ev);
- GrafPtr svGrafPtr;
- ::GetPort(&svGrafPtr);
- GrafPtr grafPtr = aqWindow->GetPlatformWindow(ev);
- ::SetPort(grafPtr);
- FW_SPlatformPoint svOrigin(grafPtr->portRect.left, grafPtr->portRect.top);
- ::SetOrigin(0,0);
- ::GlobalToLocal(&mousePos);
- ::SetOrigin(svOrigin.h, svOrigin.v);
- ::SetPort(svGrafPtr);
- #endif
-
- #ifdef FW_BUILD_WIN
- // Use the global coordinate because the lParam field gets replaced if the event
- // is an embedded mouse event
- // !!! May need to worry about scrolling here
- ::ScreenToClient((HWND)fEvent.hwnd, &mousePos);
- // [WIN_PORT] fEvent.hwnd is a void* not an HWND!
- #endif
- }
-
- FW_CPoint position = mousePos;
- if (coordinate == kFrame) {
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- FW_CAcquiredODTransform aqWindowFrameTransform = fFacet->AcquireWindowFrameTransform(ev, NULL);
- #else
- FW_CAcquiredODTransform aqWindowFrameTransform = fFacet->GetWindowFrameTransform(ev, NULL);
- #endif
- position.InverseTransform(ev, aqWindowFrameTransform);
- }
-
- return position;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsLeftButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsLeftButtonPressed(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return TRUE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kLeftMouseButton) ? TRUE : (fEvent.wParam & MK_LBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsMiddleButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsMiddleButtonPressed(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return FALSE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kMiddleMouseButton) ? TRUE : (fEvent.wParam & MK_MBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsRightButtonPressed
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsRightButtonPressed(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return FALSE;
- #endif
- #ifdef FW_BUILD_WIN
- return (fWhichButton == kRightMouseButton) ? TRUE : (fEvent.wParam & MK_RBUTTON) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsExtendModifier
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsExtendModifier(Environment* ev) const
- {
- if (fButtonState != kMouseButtonDown)
- return FALSE;
- else
- #ifdef FW_BUILD_MAC
- return (fEvent.modifiers & shiftKey) != 0;
- #endif
- #ifdef FW_BUILD_WIN
- return (fEvent.wParam & MK_SHIFT) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsItemModifier
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::IsItemModifier(Environment* ev) const
- {
- if (fButtonState != kMouseButtonDown)
- return FALSE;
- else
- #ifdef FW_BUILD_MAC
- return (fEvent.modifiers & cmdKey) != 0;
- #endif
- #ifdef FW_BUILD_WIN
- return (fEvent.wParam & MK_CONTROL) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::WaitMouseMoved
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CMouseEvent::WaitUntilMouseMoved(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return ::WaitMouseMoved(fEvent.where);
- #endif
- #ifdef FW_BUILD_WIN
- MSG event;
- BOOL bMoved = FALSE;
- DWORD InitialTick = ::GetTickCount();
- HWND hwnd = fFacet->GetWindow(ev)->GetPlatformWindow(ev);
- /* Don't capture the mouse if we're minimized!
- */
- if(IsIconic(hwnd))
- return FALSE;
-
- ::SetCapture(hwnd);
- do
- {
- ::GetMessage(&event,NULL,NULL,NULL);
- ::TranslateMessage(&event); // Translates virtual key codes
- ::DispatchMessage(&event); // Dispatches message to window
-
- if ( (event.message == WM_LBUTTONUP)
- || (event.message == WM_RBUTTONUP)
- || (event.message == WM_LBUTTONDOWN)
- || (event.message == WM_RBUTTONDOWN)
- || (event.message == WM_CHAR)
- || (::GetTickCount() < InitialTick)
- || (::GetTickCount() > InitialTick+300)
- )
- break;
- else if (event.message == WM_MOUSEMOVE)
- {
- int deltax = fEvent.pt.x - event.pt.x;
- if (deltax<0) deltax *= -1;
- int deltay = fEvent.pt.y - event.pt.y;
- if (deltay<0) deltay *= -1;
- bMoved = ((deltay >= 3) || (deltax >= 3));
- }
- } while(!bMoved);
- ::ReleaseCapture();
-
- return bMoved;
- #endif
-
- }
-
- //========================================================================================
- // CLASS FW_CEmbeddedMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- short numOfClicks) :
- FW_CMouseEvent(ev, theEvent, theFacet, theState, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CMouseEvent(ev, theFacet, theState, initialButton, theWindow, when, where, modifiers, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = kODEvtMouseDownEmbedded;
- else
- fEvent.what = kODEvtMouseUpEmbedded;
- #endif
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- fEvent.message = kODEvtMouseDownEmbedded;
- else
- fEvent.message = kODEvtMouseUpEmbedded;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::FW_CEmbeddedMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& other) :
- FW_CMouseEvent(ev, other)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::~FW_CEmbeddedMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CEmbeddedMouseEvent::~FW_CEmbeddedMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::GetEmbeddedFrame
- //----------------------------------------------------------------------------------------
- ODFrame* FW_CEmbeddedMouseEvent::GetEmbeddedFrame(Environment* ev) const
- {
- return fEmbeddedFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddedMouseEvent::GetEmbeddedFacet
- //----------------------------------------------------------------------------------------
- ODFacet* FW_CEmbeddedMouseEvent::GetEmbeddedFacet(Environment* ev) const
- {
- return fEmbeddedFacet;
- }
-
- //========================================================================================
- // CLASS FW_CBorderMouseEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev, ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- short numOfClicks) :
- FW_CMouseEvent(ev, theEvent, theFacet, theState, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks) :
- FW_CMouseEvent(ev, theFacet, theState, initialButton, theWindow, when, where, modifiers, numOfClicks),
- fEmbeddedFrame(theEmbeddedFrame),
- fEmbeddedFacet(theEmbeddedFacet)
- {
- #ifdef FW_BUILD_MAC
- if (theState == kMouseButtonDown)
- fEvent.what = kODEvtMouseDownBorder;
- else
- fEvent.what = kODEvtMouseUpBorder;
- #endif
- #ifdef FW_BUILD_WIN
- if (theState == kMouseButtonDown)
- fEvent.message = kODEvtMouseDownBorder;
- else
- fEvent.message = kODEvtMouseUpBorder;
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::FW_CBorderMouseEvent(Environment* ev, const FW_CBorderMouseEvent& other) :
- FW_CMouseEvent(ev, other)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::~FW_CBorderMouseEvent
- //----------------------------------------------------------------------------------------
- FW_CBorderMouseEvent::~FW_CBorderMouseEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::GetEmbeddedFrame
- //----------------------------------------------------------------------------------------
- ODFrame* FW_CBorderMouseEvent::GetEmbeddedFrame(Environment* ev) const
- {
- return fEmbeddedFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBorderMouseEvent::GetEmbeddedFacet
- //----------------------------------------------------------------------------------------
- ODFacet* FW_CBorderMouseEvent::GetEmbeddedFacet(Environment* ev) const
- {
- return fEmbeddedFacet;
- }
-
-
- //========================================================================================
- // CLASS FW_CVirtualKeyEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev,
- ODEventData* theEvent,
- KeyboardState theKeyboardState,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theEvent),
- fKeyboardState(theKeyboardState),
- fRepeatCount(repeatCount)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev,
- KeyboardState theKeyboardState,
- short keyCode,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theWindow, when),
- fKeyboardState(theKeyboardState),
- fRepeatCount(repeatCount)
- {
- #ifdef FW_BUILD_MAC
- if (theKeyboardState == kKeyDown)
- {
- if (repeatCount > 0)
- fEvent.what = autoKey;
- else
- fEvent.what = keyDown;
- }
- else
- fEvent.what = keyUp;
-
- fEvent.message = keyCode << 8;
- #endif
-
- #ifdef FW_BUILD_WIN
- if (theKeyboardState == kKeyDown)
- fEvent.message = WM_KEYDOWN;
- else
- fEvent.message = WM_KEYUP;
-
- fEvent.wParam = keyCode;
- fEvent.lParam = repeatCount;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::FW_CVirtualKeyEvent(Environment* ev, const FW_CVirtualKeyEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fKeyboardState = other.GetKeyboardState(ev);
- fRepeatCount = other.GetRepeatCount(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::~FW_CVirtualKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CVirtualKeyEvent::~FW_CVirtualKeyEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::GetKeyCode
- //----------------------------------------------------------------------------------------
- short FW_CVirtualKeyEvent::GetKeyCode(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return fEvent.message & keyCodeMask;
- #endif
- #ifdef FW_BUILD_WIN
- return fEvent.wParam;
- #endif
- }
-
- //========================================================================================
- // CLASS FW_CCharKeyEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev, ODEventData* theEvent, unsigned short repeatCount) :
- FW_CSystemEvent(ev, theEvent),
- fRepeatCount(repeatCount)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev,
- char keyChar,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount) :
- FW_CSystemEvent(ev, theWindow, when),
- fRepeatCount(repeatCount)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = keyDown;
- fEvent.message = keyChar;
- #endif
-
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_CHAR;
- fEvent.wParam = keyChar;
- fEvent.lParam = repeatCount;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::FW_CCharKeyEvent(Environment* ev, const FW_CCharKeyEvent& other) :
- FW_CSystemEvent(ev, other)
- {
- fRepeatCount = other.GetRepeatCount(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::~FW_CCharKeyEvent
- //----------------------------------------------------------------------------------------
- FW_CCharKeyEvent::~FW_CCharKeyEvent()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::GetChar
- //----------------------------------------------------------------------------------------
- char FW_CCharKeyEvent::GetChar(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return (char)fEvent.message & charCodeMask;
- #endif
- #ifdef FW_BUILD_WIN
- return (char)fEvent.wParam;
- #endif
- }
-
- //========================================================================================
- // CLASS FW_CActivateEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev, ODEventData* theEvent, ODFacet* facet, FW_Boolean theState) :
- FW_CSystemEvent(ev, theEvent),
- fActivationState(theState),
- fFacet(facet)
- {
- #ifdef FW_BUILD_MAC
- fPlatformWindow = (ODPlatformWindow)fEvent.message;
- #endif
- #ifdef FW_BUILD_WIN
- fPlatformWindow = (ODPlatformWindow)LOWORD(fEvent.lParam);
- // [WIN_PORT] Messge param cracking for Win32/Win16 -- different!
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev, ODFacet* facet,
- FW_Boolean theState,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when) :
- FW_CSystemEvent(ev, theWindow, when),
- fActivationState(theState),
- fFacet(facet)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = activateEvt;
- fEvent.message = (long)theWindow;
- if (theState)
- fEvent.modifiers = activeFlag;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = WM_ACTIVATE;
- if (theState)
- fEvent.wParam = WA_ACTIVE;
- else
- fEvent.wParam = WA_INACTIVE;
- fEvent.lParam = (LPARAM) theWindow;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::FW_CActivateEvent(Environment* ev, const FW_CActivateEvent& other) :
- FW_CSystemEvent(ev, other),
- fActivationState(other.fActivationState),
- fFacet(other.fFacet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::~FW_CActivateEvent
- //----------------------------------------------------------------------------------------
- FW_CActivateEvent::~FW_CActivateEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CSuspendResumeEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::FW_CSuspendResumeEvent(Environment* ev,
- ODEventData* theEvent,
- ODFacet* facet,
- FW_Boolean isGoingToBackground) :
- FW_CSystemEvent(ev, theEvent),
- fIsGoingToBackground(isGoingToBackground),
- fFacet(facet)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::FW_CSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& other) :
- FW_CSystemEvent(ev, other),
- fIsGoingToBackground(other.fIsGoingToBackground)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::~FW_CSuspendResumeEvent
- //----------------------------------------------------------------------------------------
- FW_CSuspendResumeEvent::~FW_CSuspendResumeEvent()
- {
- }
-
- //========================================================================================
- // CLASS FW_CMenuEvent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev, ODEventData* theEvent, ODCommandID theCommandID) :
- FW_CSystemEvent(ev, theEvent),
- fCommandID(theCommandID)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev,
- ODCommandID theCommandID,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when) :
- FW_CSystemEvent(ev, theWindow, when),
- fCommandID(theCommandID)
- {
- #ifdef FW_BUILD_MAC
- fEvent.what = kODEvtMenu;
- fEvent.message = theCommandID; // !!! this is wrong. should be menu item and id
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.message = kODEvtMenu;
- fEvent.wParam = theCommandID;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::FW_CMenuEvent(Environment* ev, const FW_CMenuEvent& other) :
- FW_CSystemEvent(other)
- {
- fCommandID = other.GetCommandID(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::~FW_CMenuEvent
- //----------------------------------------------------------------------------------------
- FW_CMenuEvent::~FW_CMenuEvent()
- {
- }
-